<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.util.ValueUtil"%>
<%@page import="com.shsh.safemanage.model.ProblemBrowseCondition"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.model.ShutdownType"%>
<%@page import="com.shsh.safemanage.model.Shutdown"%>
<%@page import="com.shsh.safemanage.util.RequestUtil"%>

<%
Integer problemType = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROBLEM_TYPE, (Integer)null);
if(problemType==null){
return;
}
String problemName = Problem.getProblemName(problemType);
DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
ProblemDao problemDao = DaoCreator.createProblemDao();

List<ShutdownType> shutdownTypeList = problemDao.getShutdownTypeList(false);

String theFromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
String sessionKey = Shutdown.getBrowseSessionKey(problemType);
if (theFromPage == null || !theFromPage.equals("feedback")) {
	session.removeAttribute(sessionKey);
}
%>

<script type="text/javascript">
<%
ProblemBrowseCondition theCondition = (ProblemBrowseCondition) session.getAttribute(sessionKey);
%>
function initPageValues() {
<%
if (theCondition != null) {
%>
	var depart1IDStr = '<%=ValueUtil.getString(theCondition.getDepart1IDStr())%>';
	var equipIDStr = '<%=ValueUtil.getString(theCondition.getEquipIDStr())%>';
	var shutdownTypeIDStr = '<%=ValueUtil.getString(theCondition.getShutdownTypeIDStr())%>';
	var escalateZongbuStr = '<%=ValueUtil.getString(theCondition.getEscalateZongbuStr())%>';
	var problemTitle = '<%=ValueUtil.getString(theCondition.getProblemTitle())%>';
	var problemContent = '<%=ValueUtil.getString(theCondition.getProblemContent())%>';
	var dateStart = '<%=ValueUtil.getString(theCondition.getDateStart())%>';
	var dateEnd = '<%=ValueUtil.getString(theCondition.getDateEnd())%>';
	
	setElementValueByID('depart1', depart1IDStr);
	loadPageSection(
		'<%=request.getContextPath()%>/equip_select/equipment_of_depart_select_section.jsp',
		'equipOfDepartSpan', {
			depart1ID : depart1IDStr
		}, false, function() {
			setElementValueByID('equipID', equipIDStr);
		});
	setElementValueByID('shutdownType', shutdownTypeIDStr);
	if(document.getElementById('escalateZongbu')!=null) {
		if(escalateZongbuStr=='true'){
			$('#escalateZongbu').attr('checked', true);
		} else if (escalateZongbuStr=='false'){
			$('#escalateZongbu').attr('checked', false);
		}
	}
	
	setElementValueByID('problemTitle', problemTitle);
	setElementValueByID('problemContent', problemContent);
	setElementValueByID('dateStart', dateStart);
	setElementValueByID('dateEnd', dateEnd);
<%
}
%>
}
</script>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台
	&gt;&gt; <%=problemName %>浏览
</div>
<div class="tt"><%=problemName %>浏览</div>
<div class="content">
	<div class="apptab">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			style="font-size: 12px; color: #000; line-height: 25px;">
			<tr>
				<td width="13" class="appbg">&nbsp;</td>
				<td width="97" class="appbg"><img src="images/trace.gif"
					style="vertical-align: middle;" />查询条件</td>
				<td width="554" class="appbg">&nbsp;</td>
				<td colspan="2" class="appbg">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3">
					<span style="margin-left: 30px">作业部：</span>
					<span> 
					<%@include file="/depart_select/depart1_shiyebu_select_section.jsp"%>
					</span> 
					<span style="margin-left: 10px">装置：</span> 
					<span id="equipOfDepartSpan">
						<%@include file="/equip_select/equipment_of_depart_select_section.jsp"%>
					</span>				
					<br />
					<span style="margin-left: 30px"><%=problemName %>性质：</span>						
					<span>
					<select id="shutdownType">
						<option value="0">请选择<%=problemName %>性质</option>
						<%for (ShutdownType shutdownType : shutdownTypeList) {%>
						<option value="<%=shutdownType.getId()%>"><%=shutdownType.getShutdownType()%></option>
						<%} %>
					</select>
					</span>
<%
if(problemType != null && problemType == Constants.PROBLEM_TYPE_NOTPLANED_SHUTDOWN) {
%>
					<span style="margin-left: 30px; ">
						<input type="checkbox" id="escalateZongbu" name="escalateZongbu" value="true"/>
						<label for="escalateZongbu">上报总部</label>
					</span>
<%
}
%> 
					<br/>
					
					<span style="margin-left: 30px"><%=problemName %>名称： </span><input type="text" size="15" id="problemTitle" />
					<span style="margin-left: 10px"><%=problemName %>经过： </span><input type="text" size="25" id="problemContent" />
					<font color="#666666">（可模糊查询相关文字）</font>
					
					<br />
					
					<span style="margin-left: 30px">填报日期区间：</span> <input type="text" id="dateStart"
					size="15"
					onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'dateStart\')||\'2050-12-31\'}'})" />-<input
					type="text" id="dateEnd" size="15"
					onfocus="WdatePicker({minDate:'#F{$dp.$D(\'dateEnd\')}',maxDate:'2050-12-31'})" />
				</td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3" style="text-align: center;"><a
					href="javascript:" onclick="browseProblems(1)"><img
						src="images/cha.gif" /></a></td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5">
				<span id="monthSpan">
					<%@include file="/month_href_section.jsp" %>
				</span>
				</td>
			</tr>
			<tr>
				<td colspan="5" height="20">&nbsp;</td>
			</tr>
		</table>
	</div>
	<div class="apptab" id="shutdownBrowseListTD">
	<%@include file="shutdown_list.jsp"%>
	</div>
</div>

<script type="text/javascript">
	function browseProblems(pageNum) {
		var escalateZongbu = null;
		if(document.getElementById('escalateZongbu')!=null){
			escalateZongbu = $('#escalateZongbu').attr('checked');
		}
		
		openWaitingDialog('waitingDialog');
		loadPageSection('<%=request.getContextPath()%>/shutdown/shutdown_search_list.jsp', 'shutdownBrowseListTD',
				{
					problemType: <%=problemType%>,
					departmentID : getElementValueByID('depart1'),
					equipID : getElementValueByID('equipID'),
					problemTitle : getElementValueByID('problemTitle'),
					problemContent : getElementValueByID('problemContent'),
					shutdownTypeID : getElementValueByID('shutdownType'),
					escalateZongbu: escalateZongbu,
					dateStart : getElementValueByID('dateStart'),
					dateEnd : getElementValueByID('dateEnd'),
					manageGroupID : getElementValueByID('manageGroupID'),
					pageNum: pageNum
				});
	}
	
	function browseAllProblemByMonth(dateStart, dateEnd) {
		loadPageSection('<%=request.getContextPath()%>/shutdown/shutdown_search_list.jsp', 'shutdownBrowseListTD',
		{
			problemType: <%=problemType%>,
			dateStart : dateStart,
			dateEnd : dateEnd
		}, true);
	}
	function browseOverallProblems(pageNum) {
		loadPageSection('<%=request.getContextPath()%>/shutdown/shutdown_list.jsp', 'problemBrowseListTD', 
		{
			problemType: <%=problemType%>,
			pageNum: pageNum
		}, 
		true
		);
	}
	function selectDepart1() {
		loadPageSection(
				'<%=request.getContextPath()%>/equip_select/equipment_of_depart_select_section.jsp',
				'equipOfDepartSpan', {
					depart1ID : getElementValueByID('depart1')
				}, false, function() {
					document.getElementById('equipID').value = '';
				});
		loadPageSection(
				'<%=request.getContextPath()%>/managegroup_select/manage_group_select_section.jsp',
				'manageGroupSpan', {
					depart1ID : getElementValueByID('depart1')
				}, false, function() {
					document.getElementById('manageGroupID').value = '';
				});
	}

	selectDepart1();
	initPageValues();
</script>
